#pragma once

#include "BasicEvent.h"
#include "XString.h"

namespace events {


class FileEvent : public BasicEvent
{
public:
	enum FileEventType {
		FE_OPEN,
		FE_CLOSE,
		FE_READ,
		FE_WRITE
	};

public:
	inline FileEvent(void)
		: BasicEvent(BasicEvent::EVENT_FILE_IO)
	{}

	inline FileEvent(FileEventType type)
		: BasicEvent(BasicEvent::EVENT_FILE_IO),
		  _fetype(type)
	{}

	void setFileName(const platform::XString &fname) { _fname = fname; }
	void setFileHandle(HANDLE h) { _handle = h; }

	virtual ~FileEvent(void) {}


	// implementing ISerializable
public:
	virtual void saveToStream(std::ostream &os) const;
	virtual void readFromStream(std::istream &is);
	virtual void writeDebugInfo(std::ostream &os) const;


private:
	FileEventType _fetype;
	platform::XString _fname;
	GenericDataType<HANDLE> _handle;
};


}  // end namespace